using System;
using System.Web;
using System.Web.UI;
using DemoPress.BlogServices;

namespace DemoPress.Web
{
    public class DemoPageContent: UserControl
    {
        private string _targetControl;
        private const string CONTEXTKEY = "DemoPressBlogService";
        private BlogService _blogService;

        protected BlogService BlogService
        {
            get
            {
                if (_blogService == null)
                {
                    _blogService = (BlogService)HttpContext.Current.Items[CONTEXTKEY];
                }
                return _blogService;
            }
        }
        public string TargetControl
        {
            get { return _targetControl; }
            set
            {
                _targetControl = value;
            }
        }

        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            this.Controls.Clear();
            Control control = LoadControl(this.BlogService.Theme.LoadPath(TargetControl));
            this.Controls.Add(control);
        }
    }
}
